package com.moss.cloud.auth.biz.model;

import com.moss.cloud.common.core.model.vo.UserInfo;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * 自定义用户信息
 * @author 瑾年
 * @data 2023年3月6
 */
public class UserPrincipal implements UserDetails {
    private UserInfo userInfo;
    private Set<GrantedAuthority> authorities;
    public UserPrincipal(UserInfo userInfo, Set<GrantedAuthority> authorities){
        this.userInfo=userInfo;
        this.authorities=authorities;
    }

    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }


    public String getPassword() {
        return userInfo.getPassword();
    }


    public String getUsername() {
        return userInfo.getUsername();
    }


    public boolean isAccountNonExpired() {
        return userInfo.getAccountNonExpired();
    }


    public boolean isAccountNonLocked() {
        return userInfo.getAccountNonLocked();
    }


    public boolean isCredentialsNonExpired() {
        return userInfo.getCredentialsNonExpired();
    }


    public boolean isEnabled() {
        return userInfo.getEnabled();
    }

    public Long getTenantId(){
        return userInfo.getTenantId();
    }
    public Long getUserId(){
        return userInfo.getId();
    }
    public Long getDeptId(){
        return userInfo.getDeptId();
    }

    public List<Long> getRoleIds(){
        return userInfo.getRoleIds();
    }
    public List<String> getRoleCodes(){
        return userInfo.getRoleCodes();
    }
}
